<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>测试核心库</title>
	
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
   <a href="jstlcore.do">测试核心库</a>
   <hr>
   <li>测试c:out</li><br>
   name(default)：<c:out value="${name}" /><br>
   name(EL表达式)：${name}<br>
   name(default="123")：<c:out value="${xxx}" default="123" /><br>
   name(default="123")：<c:out value="${xxx}" >123</c:out><br>
   html(default)：<c:out value="${html}" /><br>
   html(default)：<c:out value="${html}" escapeXml="false"/><br>
   html：${html}<br>
   <li>测试c:set和c:remove</li><br>
   <c:set value="112233" var="temp"></c:set>
   temp：${temp}<br>
   <c:remove var="temp" />
   after remove->temp：${temp}<br>
   <li>测试c:if</li><br>
   <c:if test="${v1 lt v2}" var="v">
   		v1小于v2<br>
   		v=${v }<br>
   </c:if>
   <c:if test="${empty v3}" >
   		v3为空<br>
   </c:if>
   <c:if test="${empty v4}" var="v4">
   		v4为空<br>
   </c:if>
   v4=${v4 }<br>
   <li>测试条件控制标签c:choose,c:when,c:otherwise</li><br>
   <c:choose>
   		<c:when test="${v1 lt v2}">
   			v1小于v2<br>
   		</c:when>
   		<c:otherwise>
   			v1大于v2<br>
   		</c:otherwise>
   	</c:choose>
   	<c:choose>
   		<c:when test="${empty v4}">
   			v4为空<br>
   		</c:when>
   		<c:otherwise>
   			v4不为空<br>
   		</c:otherwise>
   	</c:choose>
   	<li>测试循环控制标签c:forEach(varStatus,begin,end,step)</li><br>
   	<c:choose>
   		<c:when test="${empty users}">
   			集合为空
   		</c:when>
   		<c:otherwise>
   			<table border="1">
   			<c:forEach items="${users}" var="user" varStatus="i" begin="2" end="9" step="2">
   				<c:choose>
   					<c:when test="${i.count % 2==0}">
   						<tr bgcolor="red">
   					</c:when>
   					<c:otherwise>
   						<tr bgcolor="yellow">
   					</c:otherwise>
   				</c:choose>
			   				<td>
			   					name:${user.name }
			   				</td>
			   				<td>
			   					group:${user.group.name }
			   				</td>
			   				<td>
			   					i=${i.count }
			   				</td>
			   				<td>
			   					index=${i.index }
			   				</td>
   						</tr>
   			</c:forEach></table>
   		</c:otherwise>
   	</c:choose>
   	<li>测试循环控制标签c:forEach,普通循环</li><br>
   	<c:forEach begin="1" end="5">
   		test&nbsp;
   	</c:forEach>
   	<li>测试循环控制标签c:forEach,输出Map</li><br>
   	<c:forEach items="${map}" var="v">
   		${v.key }=${v.value }<br>
   	</c:forEach>
   	
   	<li>测试循环控制标签c:forTokens</li><br>
	<%request.setAttribute("tokens","a,b,c"); %>
   	<c:forTokens items="${tokens}" delims="," var="v">
   		${v }&nbsp;
   	</c:forTokens>
   	<li>测试c:catch</li><br>
   	<%
   		try{
   			Integer.parseInt("string");
   		}catch(Exception e){
   			out.println(e.getMessage());
   		}
   	%><br>
   	<c:catch var="exinfo">
   	<%
   		Integer.parseInt("string");
   	%>
   	</c:catch>
   	${exinfo }<br>
   	<li>测试c:import</li><br>
   	<c:import url="http://localhost/test/display.jsp"></c:import>
   	<li>测试c:url和c:param</li><br>
   	<c:url value="http://localhost/test/display.jsp" var="v">
   		<c:param name="username" value="jqb"></c:param>
   		<c:param name="age" value="23"></c:param>
   	</c:url>
   	url=${v }<br>
   	<li>测试c:redirect</li><br>
  	<%//<c:redirect context="/webjstl" url="/display.jsp"></c:redirect>%>
  </body>
</html>














